package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CustomerAppointmentsMapper;
import com.ruoyi.system.domain.CustomerAppointments;
import com.ruoyi.system.service.ICustomerAppointmentsService;

/**
 * 客户预约信息Service业务层处理
 * 
 * @author LK
 * @date 2024-06-22
 */
@Service
public class CustomerAppointmentsServiceImpl implements ICustomerAppointmentsService 
{
    @Autowired
    private CustomerAppointmentsMapper customerAppointmentsMapper;

    /**
     * 查询客户预约信息
     * 
     * @param customerId 客户预约信息主键
     * @return 客户预约信息
     */
    @Override
    public CustomerAppointments selectCustomerAppointmentsByCustomerId(String customerId)
    {
        return customerAppointmentsMapper.selectCustomerAppointmentsByCustomerId(customerId);
    }

    /**
     * 查询客户预约信息列表
     * 
     * @param customerAppointments 客户预约信息
     * @return 客户预约信息
     */
    @Override
    public List<CustomerAppointments> selectCustomerAppointmentsList(CustomerAppointments customerAppointments)
    {
        return customerAppointmentsMapper.selectCustomerAppointmentsList(customerAppointments);
    }

    /**
     * 新增客户预约信息
     * 
     * @param customerAppointments 客户预约信息
     * @return 结果
     */
    @Override
    public int insertCustomerAppointments(CustomerAppointments customerAppointments)
    {
        Random rand = new Random();
        // 生成6位
        int randomNumber = rand.nextInt(900000)  + 100000;
        // 随机分配字符
        customerAppointments.setTechnicianId(String.valueOf(randomNumber));
        return customerAppointmentsMapper.insertCustomerAppointments(customerAppointments);
    }

    /**
     * 修改客户预约信息
     * 
     * @param customerAppointments 客户预约信息
     * @return 结果
     */
    @Override
    public int updateCustomerAppointments(CustomerAppointments customerAppointments)
    {
        return customerAppointmentsMapper.updateCustomerAppointments(customerAppointments);
    }

    /**
     * 批量删除客户预约信息
     * 
     * @param customerIds 需要删除的客户预约信息主键
     * @return 结果
     */
    @Override
    public int deleteCustomerAppointmentsByCustomerIds(String[] customerIds)
    {
        return customerAppointmentsMapper.deleteCustomerAppointmentsByCustomerIds(customerIds);
    }

    /**
     * 删除客户预约信息信息
     * 
     * @param customerId 客户预约信息主键
     * @return 结果
     */
    @Override
    public int deleteCustomerAppointmentsByCustomerId(String customerId)
    {
        return customerAppointmentsMapper.deleteCustomerAppointmentsByCustomerId(customerId);
    }
}
